//要使用克隆功能，首先要    implement  Cloneable；使用接口表明这个类可以被克隆
//需要在子类中再次声明克隆方法，因为克隆方法是在不同的包中且由protected修饰的，需要用super重写此方法，
//也就是说在主函数中不能直接使用其他包中由protected修饰的类，必须经过子类实例化调用，而子类也必须重写此方法
class Student implements Cloneable{
    String name;
    int age;
    public Student(String name , int age){
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
public class Test_9_8 {
    public static void main(String[] args) throws CloneNotSupportedException{
        String name = "张三";
        int age = 14 ;
        Student student = new Student(name,age);
        Student student1 = (Student) student.clone();
        System.out.println(student.toString());
        System.out.println(student1.toString());
    }
}
/**
 * @param t
 * new Student(name,age)
 */
